package slidingwindow;

/**
 * Created by fengliejv on 2017/11/17.
 */
public class ContainerWithMostWater11 {
    public int maxArea(int[] height) {
        if(height.length<=1){
            return 0;
        }
        int begin = 0;
        int end = height.length-1;
        int max=0;
        while (begin<end){
            int area = (end-begin)*Math.min(height[begin],height[end]);
            if(area>max){
                max=area;
            }
            if(height[begin]>height[end]){
                end--;
            }else {
                begin++;
            }
        }
        return max;
    }
}
